package com.lujianfei.filesend.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.lujianfei.common.LogUtils

abstract class BaseActivity<DB: ViewDataBinding?>: AppCompatActivity() {

    protected var binding: DB?= null

    abstract fun resourceId():Int
    abstract fun initView()
    abstract fun initData()
    abstract fun initEvent()

    inline fun <reified VM:ViewModel> buildViewModel() = ViewModelProvider(this)[VM::class.java]

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView<DB>(this, resourceId())
        initView()
        initEvent()
        initData()
        LogUtils.d("BaseActivity=",  "${localClassName}")
    }
}